Ext.define('DragonApp.view.order.Controller', {
    extend: 'Ext.app.ViewController',

    alias: 'controller.order',

    requires: [
        'DragonApp.util.Msg'
    ],

    onSubmitClick: function(button, e, options) {

        var me = this;
        var form = this.getView().getForm();

        if (!form.isValid()) return;

        var formValue = form.getValues();

        var grid = Ext.ComponentQuery.query('ordergrid')[0];
        var store = grid.getStore();

        grid.mask('查询中...');

        //根据查询附加参数加载数据仓库

        store.load({
            params: formValue,
            scope: this,
            callback: function(records, operation, success) {
                grid.unmask();
                if (success == false) {
                    store.removeAll();
                }
            }
        });
    },

    onTextFieldSpecialKey: function(field, e, options) {
        if (e.getKey() === e.ENTER) {
            if (this.getView().getForm().isValid()) {
                this.onSubmitClick();
            }
        }
    }
});